<template>
	<div>
		<el-result icon="success" title="本次采集已提交">
			<template #extra>
				<el-descriptions class="mt10" :column="1">
					<template #title>
						<span class="text-gray mr8">请等待平台进行校验和比对</span>
					</template>
					<template #extra>
						<el-button v-if="scheduleBtn" @click="drawer = !drawer"> 查看进度 </el-button>
					</template>
					<el-descriptions-item label="采集批次号">
						{{ gatherObj.batchNumber }}
					</el-descriptions-item>
					<!-- <el-descriptions-item label="变更数据批次号" v-show="changeBatchNumber">
						{{ changeBatchNumber }}
					</el-descriptions-item> -->
					<el-descriptions-item label="采集人">
						{{ gatherObj.gathererName }}
					</el-descriptions-item>
					<el-descriptions-item label="采集时间">
						{{ gatherObj.createTime }}
					</el-descriptions-item>
					<el-descriptions-item label="采集内容"> {{ gatherObj.gatherContent }}条 </el-descriptions-item>
				</el-descriptions>
				<div class="operate" v-if="nextBtn">
					<el-button type="primary" @click="getInitMod"> 再次采集 </el-button>
					<el-button @click="handleBack">返回</el-button>
				</div>
			</template>
		</el-result>
		<el-drawer v-model="drawer" title="数据采集明细" append-to-body size="65%">
			<DataGather v-if="drawer" :dataType="dataType" :batchNumber="gatherObj.batchNumber"></DataGather>
		</el-drawer>
	</div>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod'
import DataGather from './index.vue'
type Props = {
	gatherObj?: any
	dataType: string | number
	nextBtn?: boolean
	scheduleBtn?: boolean
}
const props = withDefaults(defineProps<Props>(), {
	nextBtn: true,
	scheduleBtn: true,
})

const emit = defineEmits(['init', 'back'])
const changeBatchNumber = ref('')
const drawer = ref(false)
const getInitMod = () => {
	emit('init')
}
const handleBack = () => {
	emit('back')
}

const getChangeNumber = () => {
	if (props.gatherObj.batchNumber) {
		apiMod.view_dpDataChange_getDataChangeId(props.gatherObj.batchNumber).then((res) => {
			changeBatchNumber.value = res.data
		})
	}
}

watch(
	() => props.gatherObj.batchNumber,
	(val) => {
		getChangeNumber()
	},
	{
		immediate: true,
	}
)
</script>

<style scoped></style>
